//
//  MSMeCell.m
//  MS
//
//  Created by He Yuan on 13-2-22.
//  Copyright (c) 2013年 He Yuan. All rights reserved.
//

#import "UIColor+ColorUtils.h"
#import "MSMeCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation MSMeCell
@synthesize timeBtn;
@synthesize commentCountLbl; //评论
@synthesize commentButton;
@synthesize likeCountLbl; //喜欢
@synthesize likeButton;
@synthesize imageAndTxtView;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        timeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        UIImage *img = [UIImage imageNamed:@"me_cell_time"];
        [timeBtn setFrame:CGRectMake(-2, 10, img.size.width, img.size.height)];
        [timeBtn setBackgroundImage:img forState:UIControlStateNormal];
        [timeBtn.titleLabel setBackgroundColor:[UIColor redColor]];
        UILabel *lbl = [MSTool createLable:CGRectMake(0,-1, img.size.width, 25)];
        [lbl setBackgroundColor:[UIColor clearColor]];
        [lbl setFont:[UIFont systemFontOfSize:8.0]];
        [lbl setTextColor:[UIColor whiteColor]];
        [lbl setTextAlignment:UITextAlignmentCenter];
        lbl.numberOfLines = 0;
        lbl.tag = 1;
        [timeBtn addSubview:lbl];
        [self.contentView addSubview:timeBtn];
        
        commentCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(30.0,64,30.0, 14.0f)];
        [commentCountLbl setTextColor:[UIColor colorWithString:@"#85acbd"]];
        [commentCountLbl setFont:[UIFont systemFontOfSize:10]];
        [commentCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [commentCountLbl setTextAlignment:UITextAlignmentLeft];
        [commentCountLbl setBackgroundColor:[UIColor clearColor]];
        [commentCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:commentCountLbl];
        
        commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [commentButton setFrame:CGRectMake(8,45.0,31, 27)];
        [commentButton setImage:[UIImage imageNamed:@"shower_cell_comment"] forState:UIControlStateNormal];
        [commentButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:commentButton];
        
        likeCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(30,103, 30.0f, 14.0f)];
        [likeCountLbl setTextColor:[UIColor colorWithString:@"#b87691"]];
        [likeCountLbl setFont:[UIFont systemFontOfSize:10]];
        [likeCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [likeCountLbl setTextAlignment:UITextAlignmentLeft];
        [likeCountLbl setBackgroundColor:[UIColor clearColor]];
        [likeCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:likeCountLbl];
        
        likeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [likeButton setFrame:CGRectMake(8,85,31, 27)];
        [likeButton setImage:[UIImage imageNamed:@"shower_cell_like"] forState:UIControlStateNormal];
        [likeButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:likeButton];
        
        imageAndTxtView = [[MSImageAndTextCellContentView alloc]initWithFrame:CGRectMake(70,10,220,290)];
        [self.contentView addSubview:imageAndTxtView];
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
            
    if ([imageAndTxtView.txtLbl.text length]>0)
    {
        [imageAndTxtView setTxtLblHeight:CELL_TXTLBL_HEIGHT(imageAndTxtView.txtLbl.text)];
    }
    else
    {
        [imageAndTxtView setTxtLblHeight:0];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
